(function(){"use strict";BX.namespace("BX.Landing.UI.Field");var i=BX.Landing.Utils.remove;var e=BX.Landing.Utils.unbind;var t=BX.Landing.Utils.addClass;var n=BX.Landing.Utils.removeClass;var a=BX.Landing.Utils.encodeDataValue;var r=BX.Landing.Utils.prepend;var l=BX.Landing.Utils.append;var s=BX.Landing.Utils.create;var d=BX.Landing.Utils.data;var g=BX.Landing.Utils.slice;var o=BX.Landing.Utils.bind;BX.Landing.UI.Field.SortableList=function(i){BX.Landing.UI.Field.DragAndDropList.apply(this,arguments);t(this.layout,"landing-ui-field-sortable-list");this.makePreview();r(this.preview,this.target)};BX.Landing.UI.Field.SortableList.prototype={constructor:BX.Landing.UI.Field.SortableList,__proto__:BX.Landing.UI.Field.DragAndDropList.prototype,onDragStart:function(i){BX.Landing.UI.Field.DragAndDropList.prototype.onDragStart.call(this,i);t(this.preview,"landing-ui-ondrag");t(this.dragItem,"landing-ui-ondrag")},onDragEnd:function(i){BX.Landing.UI.Field.DragAndDropList.prototype.onDragEnd.call(this,i);n(this.preview,"landing-ui-ondrag");n(this.dragItem,"landing-ui-ondrag");this.makePreview()},onElementClick:function(){},makePreview:function(){if(!this.preview){this.preview=s("div",{props:{className:"landing-ui-field-sortable-list-preview"}})}this.preview.innerHTML="";this.getValue().forEach(function(i){l(this.createPreviewItem(this.getItem(i).preview,i),this.preview)},this)},createItem:function(t){var n=BX.Landing.UI.Field.DragAndDropList.prototype.createItem.call(this,t);i(n.querySelector(".landing-ui-field-dnd-list-item-remove"));e(n,"drag",this.onDrag);r(s("span",{props:{className:"landing-ui-field-dnd-list-item-drag"}}),n);o(n,"mouseover",this.highlightByValue.bind(this,t.value));o(n,"mouseout",this.removeHighLightByValue.bind(this,t.value));return n},createPreviewItem:function(i,e){return s("div",{props:{className:"landing-ui-field-sortable-list-preview-item"},attrs:{"data-value":a(e)},children:[s("img",{props:{src:i},events:{mouseover:this.highlightByValue.bind(this,e),mouseout:this.removeHighLightByValue.bind(this,e)}})]})},highlightByValue:function(i){var e=this.getPreviewByValue(i);var n=this.getElementByValue(i);if(e){t(e,"landing-ui-active")}if(n){t(n,"landing-ui-active")}},removeHighLightByValue:function(i){var e=this.getPreviewByValue(i);var t=this.getElementByValue(i);if(e){n(e,"landing-ui-active")}if(t){n(t,"landing-ui-active")}},getElementByValue:function(i){return g(this.valueArea.children).find(function(e){return d(e,"data-value")==i})},getPreviewByValue:function(i){return g(this.preview.children).find(function(e){return d(e,"data-value")==i})}}})();